<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <link rel="stylesheet" type="text/css" href="/Public/uploadfy/uploadify.css" />
    <script type="text/javascript" src="/Public/uploadfy/jquery.uploadify.min.js"></script>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <style>
        #dg{
            height: 100%;;
        }
        .text_valy td{
            line-height: 30px;
            /*border: 1px solid #000000;*/
        }
    </style>
</block>
<block name="bdoy">
    <body>
    <div id="grid_ToolBar" style="padding:5px;height:auto">
        <div id="queryParamZone">
            <form id="queryForm_gen" method="post" action="">
                <table>
                    <tr>
                        <td>调蓄池</td>
                        <td><input id="ps_id_combox"></td>
                        <td>泵机</td>
                        <td><select id="p_id" style="width: 100px;"></select></td>
                        <td>从</td>
                        <td>
                            <input class="easyui-datebox" id="gen_start" name="start_date" editable="false" value="{:date("Y-m-d")}" style="width: 100px;">
                        </td>
                        <td>至</td>
                        <td>
                            <input class="easyui-datebox" id="gen_end" name="end_date" editable="false" value="{:date("Y-m-d")}" style="width: 100px;">
                        </td>
                        <td><a id="query" href="#" class="easyui-linkbutton" iconCls="icon-search">按日期统计</a></td>
                        <td><a id="query_hour" href="#" class="easyui-linkbutton" iconCls="icon-search">按小时统计</a></td>
                     </tr>
                </table>
                <table>
                    <tr>
                        <td>
                            <div id="search_tag_content"></div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
    <div id="chart_text" style="text-align: center;width: 800px;"></div>
    <div id="main_charts" style="width: 1000px;height:400px;"></div>
    </body>
</block>
<block name="footExtendJs">
    <script>
        $(function(){
            $('#ps_id_combox').combobox({
                url:'/Manage/AdminCsdt/get_all_combox?change_all_text=1',
                valueField:'id',
                textField:'name',
                width:120,
                multiple:true,
                prompt:'支持多选',
                onSelect: function (record){
                    var text = record.name;
                    if(record.name=='全部'){
                        text = '全部调蓄池';
                    }
                    create_search_tag(text, 'ps_id', record.id);
                    $('#p_id').combobox('clear');
                    $('#p_id').combobox('reload','/Manage/AdminCsdtPump/get_all_pump?ps_id='+get_search_tag_ids('ps_id'));
                    $(this).combobox('clear');
                }
            });
            $('#p_id').combobox({
                url:'',
                valueField:'id',
                textField:'p_number',
                width:100,
                multiple:true,
                prompt:'支持多选',
                onSelect: function (record){
                    var text = record.p_number;
                    if(record.p_number=='全部'){
                        text = '全部泵机';
                    }
                    create_search_tag(text, 'f_id', record.id);
                    $(this).combobox('clear');
                }
            });
            $('#query').click(function() {
                query_fy_form(2);
            });

            $('#query_hour').click(function() {
                query_fy_form(1);
            });

            $('#bta_add_date').click(function() {
                var gen_start = $('#gen_start').combo('getValue');
                var gen_end = $('#gen_end').combo('getValue');
                if(gen_start==''||gen_end==''){
                    return;
                }
                if(gen_start>gen_end){
                    $.messager.alert('提示','起始日期不可大于终止日期！','error');
                    return;
                }
                var text = gen_start+'至'+gen_end;
                var val = gen_start+'_'+gen_end;
                create_search_tag(text, 'date', val);
            });


        });

        function query_fy_form(type){
            var gen_start = $('#gen_start').combo('getValue');
            var gen_end = $('#gen_end').combo('getValue');
            if($('#ps_id_combox').combo('getValue') == ''){
                $.messager.alert('提示','请选择调蓄池！','error');
                return;
            }
            if(gen_start==''||gen_end==''){
                $.messager.alert('提示','请选择日期！','error');
                return;
            }
            if(gen_start>gen_end){
                $.messager.alert('提示','起始日期不可大于终止日期！','error');
                return;
            }
            var obj = $('#queryForm_gen').serializeJson();
            obj['ps_id'] = get_search_tag_ids('ps_id');
            obj['f_id'] = get_search_tag_ids('f_id');
            if(type == 2){
                set_main_charts(obj);
            }else{
                set_main_charts_hour(obj);
            }
        }

        function set_main_charts(obj){
            setHeight();
//            echarts.dispose(document.getElementById('main_charts'));
            $('#main_charts').empty();
            var myChart = echarts.init(document.getElementById('main_charts'));
            myChart.showLoading({text: '正在加载，请稍后....',});
            myChart.clear();
            var url = '__URL__/mut_bz_query';
            $.post(url, obj, function(json){
                json = eval('(' + json + ')');
                myChart.setOption(json.option, true);
                $('#chart_text').text(json.text)
                myChart.hideLoading();
            });
        }

        function set_main_charts_hour(obj){
            setHeight();
            $('#main_charts').empty();
            var myChart = echarts.init(document.getElementById('main_charts'));
            myChart.showLoading({text: '正在加载，请稍后....',});
            myChart.clear();
            var url = '__URL__/mut_bz_query_hour';
            $.post(url, obj, function(json){
                json = eval('(' + json + ')');
                myChart.setOption(json.option, true);
                $('#chart_text').text(json.text)
                myChart.hideLoading();
            });
        }

        function setHeight(){

        }
    </script>
</block>